package week4.num.ExceptionDemo01.neueduTotal.card;

public class Card implements Comparable {
    /**
     * 花色
     */
    private int suit;
    /**
     * 点数
     */
    private int rank;

    public Card() {
    }

    public Card(int suit, int point) {
        this.suit = suit;
        this.rank = point;
    }

    public int getSuit() {
        return suit;
    }

    public void setSuit(int suit) {
        this.suit = suit;
    }

    public int getRank() {
        return rank;
    }

    public void setRank(int rank) {
        this.rank = rank;
    }

    /**
     * 手牌点数
     */
    public static final int THREE = 0;
    public static final int FOUR = 1;
    public static final int FIVE = 2;
    public static final int SIX = 3;
    public static final int SEVEN = 4;
    public static final int EIGHT = 5;
    public static final int NINE = 6;
    public static final int TEN = 7;
    public static final int JACK = 8;
    public static final int QUEEN = 9;
    public static final int KING = 10;
    public static final int ACE = 11;
    public static final int DEUCE = 12;
    public static final int BLACK = 13;
    public static final int COLOR = 14;
    /**
     * 手牌花色
     */
    public static final int DIAMOND = 0;
    public static final int CLUB = 1;
    public static final int HEART = 2;
    public static final int SPADE = 3;
    public static final int JOKER = 4;

    private static final String[] SUIT = {"♦", "♣", "♥", "♠", ""};
    private static final String[] RANK = {"3", "4", "5", "6", "7", "8", "9", "10", "J", "Q", "K", "A", "2", "小王", "大王"};

    /**
     * 重写toString方法
     *
     * @return 牌的花色和点数
     */
    @Override
    public String toString() {
        return SUIT[suit] + RANK[rank];
    }

    @Override
    public int compareTo(Object o) {
        Card anotherCard = (Card) o;
        if (this.rank>anotherCard.rank){
            return -1;
        }

        if (this.rank== anotherCard.rank){
            if (this.suit>anotherCard.suit){
                return -1;
            }
        }
        return 1;
    }
}
